﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net;

public partial class Help : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Form.Target = "_blank";
        this.DropDownList1.Items[0].Selected = true;
    }


    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("ContactUs.aspx");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
        smtp.EnableSsl = true;
        smtp.UseDefaultCredentials = false;

        smtp.Credentials = new NetworkCredential(TextBox6.Text, TextBox5.Text);
        MailMessage mail = new MailMessage(TextBox6.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text);
        try
        {
            if (fileUpload1.HasFile)
            {
                mail.Attachments.Add(new Attachment(fileUpload1.PostedFile.InputStream, fileUpload1.FileName));
            }
            smtp.Send(mail);

        }
        catch (Exception ex)
        {
            Response.Write("Exception Occured : " + ex);

        }
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedItem.Value == "Accounts Department")
        {
            TextBox6.Text = "shuhui_95@hotmail.com";
        }
        else if (DropDownList1.SelectedItem.Value == "Cards Department")
        {
            TextBox6.Text = "lohyewchong@hotmail.com";
        }
       
        else if (DropDownList1.SelectedItem.Value == "Insurance Department")
        {
            TextBox6.Text = "stephanie-0809@hotmail.sg";
        }
    }
}
